﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects;

namespace MINERP.DAL.InfoConfig
{
    public class ActionDAL:DALBase
    {
        private static ObjectQuery<tb_Action> GetActions()
        {
            return DataEntites.tb_Action.Include("tb_Power");
        }

        public static List<tb_Action> GetActionList()
        {
            List<tb_Action> list = new List<tb_Action>();
            foreach (var item in GetActions())
            {
                list.Add(item);
            }
            return list;
        }

        public static tb_Action GetActionObj(int id)
        {
            return DataEntites.tb_Action.First(a => a.ActionId == id);
        }

        public static void Add(tb_Action obj)

        {
            DataEntites.AddTotb_Action(obj);
            DataEntites.SaveChanges();
        }

        public static void Update()
        {
            DataEntites.SaveChanges();
        }

        public static void Delete(tb_Action obj)
        {
            DataEntites.DeleteObject(obj);
            DataEntites.SaveChanges();
        }
    }
}
